function setupTutorExportGrid() {
    $("#tutorSearch").jqGrid({
        url : 'getTutorSearchtList.action',
        datatype : "local",
        colNames : [ '序号', '姓名', '性别', '出生日期', '身份证号', '主讲课程', '讲师风格', '手机', '邮箱地址', '调用次数', '', '' ],
        colModel : [{ name : 'no', index : 'no', width : 25, sortable: false }, 
                    { name : 'name', index : 'name', width : 60 },
                    { name : 'isMale', index : 'isMale', width : 30 }, 
                    { name : 'birthday', index : 'birthday', width : 80 },
                    { name : 'idNo', index : 'idNo', width : 120 }, 
                    { name : 'major', index : 'major', width : 60 },
                    { name : 'style', index : 'style', width : 60 },
                    { name : 'cellPhone', index : 'cellPhone', width : 115 },
                    { name : 'mailAddress', index : 'mailAddress', idth : 115 },
                    { name : 'callTimes', index : 'callTimes', width : 60 },
                    { name : 'callHistory', index : 'callHistory', width : 65, sortable: false },
                    { name : 'tutorDetail', index : 'tutorDetail', width : 65, sortable: false }],
        rowNum : 10,
        height : 'auto',
        rowList : [ 10, 20, 30 ],
        pager : '#pager',
        sortname : 'id',
        viewrecords : true,
        sortorder : "desc",
        caption : "老师信息一览",
        gridComplete : function() {
            var ids = $('#tutorSearch').jqGrid('getDataIDs');
            for (var i = 0; i < ids.length; i++) {
                var id = ids[i];
                $('#tutorSearch').jqGrid('setRowData', id, {
                    callHistory : "<button class='gridBtn' onclick='toHistory(" + id + ");'>调用履历</button>",
                    tutorDetail : "<button class='gridBtn' onclick='toDetail(" + id + ");'>老师详细</button>"
                });
            }
        },
        multiselect : false,
        loadError : dealError
    });
    $("#tutorSearch").jqGrid('navGrid', '#pager', {
        edit : false,
        add : false,
        del : false
    });
}

function setupTutorExportToolbar() {
    $("#search").button({
        icons : {
            primary : "ui-icon-search"
        }
    }).click(function() {
        $("#detail").dialog("open");
    });

    $("#keywordMatch").button({
        icons : {
            primary : "ui-icon-search"
        }
    }).click(function() {
        $("#keywordDetail").dialog("open");
    });

    $("#export").button({
        icons : {
            primary: "ui-icon-copy"
        }
    }).click(function() {
        $("#tutorDetail").submit();
    });
}

function setupTutorExportDialog() {
    $("#detail").dialog({
        autoOpen : false,
        show : "slide",
        height : 600,
        width : 600,
        modal : true,
        buttons : {
            检索 : function() {
                var sexCodeArray = getSexMatchCode($("#keyword").val());
                var tutorSearch = {
                    'tutorSearch.idNo' : $("#idNo").val(),
                    'tutorSearch.name' : $("#name").val(),
                    'tutorSearch.sex' : $("#sex").val(),
                    'tutorSearch.sexCodes' : sexCodeArray.join(),
                    'tutorSearch.birthdayFrom' : $("#birthdayFrom").val(),
                    'tutorSearch.birthdayTo' : $("#birthdayTo").val(),
                    'tutorSearch.address' : $("#address").val(),
                    'tutorSearch.type' : $("#type").val(),
                    'tutorSearch.major' : $("#major").val(),
                    'tutorSearch.price' : '',
                    'tutorSearch.style' : $("#style").val(),
                    'tutorSearch.cellPhone' : $("#cellPhone").val(),
                    'tutorSearch.imAddress' : $("#imAddress").val(),
                    'tutorSearch.phone' : $("#phone").val(),
                    'tutorSearch.mailAddress' : $("#mailAddress").val(),
                    'tutorSearch.cellPhoneBak' : $("#cellPhoneBak").val(),
                    'tutorSearch.phoneBak' : $("#phoneBak").val(),
                    'tutorSearch.mailAddressBak' : $("#mailAddressBak").val(),
                    'tutorSearch.task' : $("#task").val(),
                    'tutorSearch.introduction' : $("#introduction").val(),
                    'tutorSearch.outLine' : $("#outLine").val(),
                    'tutorSearch.remark' : $("#remark").val(),
                    'tutorSearch.isOr' : false
                };
                var postData = $("#tutorSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, tutorSearch);
                $("#tutorSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            取消 : function() {
                $(this).dialog("close");
                return false;
            }
        },
        close : function() {
            ;
        }
    });

    $('#keywordDetail').dialog({
        autoOpen : false,
        show : "slide",
        height : 200,
        width : 250,
        modal : true,
        buttons : {
            筛选 : function() {
                var sexCodeArray = getSexMatchCode($("#keyword").val());
                var tutorSearch = {
                    'tutorSearch.idNo' : $("#keyword").val(),
                    'tutorSearch.name' : $("#keyword").val(),
                    'tutorSearch.sex' : -1,
                    'tutorSearch.sexCodes' : sexCodeArray.join(),
                    'tutorSearch.birthdayFrom' : '',
                    'tutorSearch.birthdayTo' : '',
                    'tutorSearch.address' : $("#keyword").val(),
                    'tutorSearch.type' : $("#keyword").val(),
                    'tutorSearch.major' : $("#keyword").val(),
                    'tutorSearch.price' : '',
                    'tutorSearch.style' : $("#keyword").val(),
                    'tutorSearch.cellPhone' : $("#keyword").val(),
                    'tutorSearch.imAddress' : $("#keyword").val(),
                    'tutorSearch.phone' : $("#keyword").val(),
                    'tutorSearch.mailAddress' : $("#keyword").val(),
                    'tutorSearch.cellPhoneBak' : $("#keyword").val(),
                    'tutorSearch.phoneBak' : $("#keyword").val(),
                    'tutorSearch.mailAddressBak' : $("#keyword").val(),
                    'tutorSearch.task' : $("#keyword").val(),
                    'tutorSearch.introduction' : $("#keyword").val(),
                    'tutorSearch.outLine' : $("#keyword").val(),
                    'tutorSearch.remark' : $("#keyword").val(),
                    'tutorSearch.isOr' : true
                };
                var postData = $("#tutorSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, tutorSearch);
                $("#tutorSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            解除筛选 : function() {
                var tutorSearch = {
                    'tutorSearch.idNo' : '',
                    'tutorSearch.name' : '',
                    'tutorSearch.sex' : -1,
                    'tutorSearch.sexCodes' : '',
                    'tutorSearch.birthdayFrom' : '',
                    'tutorSearch.birthdayTo' : '',
                    'tutorSearch.address' : '',
                    'tutorSearch.type' : '',
                    'tutorSearch.major' : '',
                    'tutorSearch.price' : '',
                    'tutorSearch.style' : '',
                    'tutorSearch.cellPhone' : '',
                    'tutorSearch.imAddress' : '',
                    'tutorSearch.phone' : '',
                    'tutorSearch.mailAddress' : '',
                    'tutorSearch.cellPhoneBak' : '',
                    'tutorSearch.phoneBak' : '',
                    'tutorSearch.mailAddressBak' : '',
                    'tutorSearch.task' : '',
                    'tutorSearch.introduction' : '',
                    'tutorSearch.outLine' : '',
                    'tutorSearch.remark' : '',
                    'tutorSearch.isOr' : true
                };
                var postData = $("#tutorSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, tutorSearch);
                $("#tutorSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            取消 : function() {
                $(this).dialog("close");
                return false;
            }
        },
        close : function() {
            ;
        }
    });
}

function toHistory(id) {
    $('#tutorId').val(id);
    $('#rForm').attr("action", "showTutorCallHistory.action");
    $('#rForm').submit();
}

function toDetail(id) {
    $('#tutorId').val(id);
    $('#rForm').attr("action", "showTutorDetail.action");
    $('#rForm').submit();
}
